#include "consumer/ConsumerController.h"

namespace zeroplus::mq
{

    ConsumerController::ConsumerController(const std::string &uri)
        : mediator_(std::make_shared<consumer::ConsumerMediator>())
    {
        Uri uriParser = Uri(uri);
        routeInfoDownloader_ = std::make_shared<consumer::RouteInfoDownloader>(mediator_, uriParser.GetUri());
        MessageSubscriber_ = std::make_shared<consumer::MessageSubscriber>(mediator_);
        mediator_->setRouteInfoDownloader(routeInfoDownloader_);
        mediator_->setMessageSubscriber(MessageSubscriber_);
    }

    ConsumerController::~ConsumerController() {}

    void ConsumerController::Start(const std::string &topic)
    {
        routeInfoDownloader_->SetTopicName(topic);
        routeInfoDownloader_->Start();
    }

}
